<template>
  <div>
    <h2>登录</h2>
    <div style="color: red;font-size: 12px">{{ errorInfo }}</div>
    <div style="width: 200px">
      用户名:
      <el-input v-model="loginObj.userName" placeholder="请输入用户名"/>
    </div>
    <br>
    <div style="width: 200px">
      密码:
      <el-input
          v-model="loginObj.pwd"
          type="password"
          placeholder="请输入密码"
          show-password
      />
    </div>
    <br>
    <el-button type="primary" @click="login()">登录</el-button>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      errorInfo: "",
      loginObj: {},
    }
  },
  methods: {
    login() {
      axios.get("/project/user/login", {params: this.loginObj}).then(resp => {
        if (resp.data == "customer") {
          this.$router.push("/shopIndex");
        } else if (resp.data == "manager") {
          this.$router.push("/managerOrder");
        } else if (resp.data == "delivery") {
          this.$router.push("/deliveryOrder")
        } else {
          this.errorInfo = "登陆失败";
        }
      })
    }
  },
}
</script>

<style scoped>

</style>